


import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 佳宝OA相关接口
 *
 * allen  2024-03-12
 */

/**
 * 
 * 订单列表
 *
 * }
 */
const orderList = (data) => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/order/list", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
* 
* 订单发货
*
* }
*/
const orderSend = (data) => {
  return new Promise((resolve, reject) => {
    put("/api/front/oa/order/send", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
* 
* 修改发货信息
*
* }
*/
const orderSendUpdate = (data) => {
  return new Promise((resolve, reject) => {
    post("/api/front/oa/order/sendUpdate", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 
 * 合伙人我的商品
 *
 * }
 */
const myShopList = (page, limit = 10) => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/product/list?page" + page + "&limit=" + limit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
* 
* 合伙人商品统计
*
* }
*/
const myShopTotalData = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/product/statistics").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
* 
* 合伙人结算列表
*
* }
*/
const settleList = (page, limit = 10) => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/settlement/record/list?page" + page + "&limit=" + limit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
* 
* 合伙人结算统计
*
* }
*/
const settleStatistics = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/settlement/statistics").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
* 
* 合伙人结算订单记录
*
* }
*/
const settleOrderList = (page, limit) => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/settlement/order/list?page=" + page + "&limit=" + limit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
* 
* 合伙人结算月清单
*
* }
*/
const settleMonthList = (page, limit) => {
  return new Promise((resolve, reject) => {
    get("/api/front/oa/settlement/month/list?page=" + page + "&limit=" + limit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



module.exports = {
  orderList,
  orderSend,
  myShopList,
  myShopTotalData,
  settleList,
  settleStatistics,
  settleOrderList,
  settleMonthList,
  orderSendUpdate,
}

